package com.heima.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component//放入容器，万能标识
public class TestListener {
/*    @KafkaListener(topics = "test-topic")
    public void getMessage(String message){
        System.out.println("收到消息");
        System.out.println(message);
    }*/

    @KafkaListener(topics = "test-topic")
    public void onMessage2(ConsumerRecord<String, String> record, Acknowledgment acknowledgment) {
        System.out.println(record.value());
        acknowledgment.acknowledge();
    }
}
